<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
	<jsp:include page="/include.jsp"/>
	<script type="text/javascript">
	
	$(function(){
		//查询表格数据
		getDatagridByID();
		//渲染问题级别下拉框
		$('#problemLevel').combobox({
			url:'${pageContext.request.contextPath}/problemmgr/problemAction!getDic.action?codeType=warnLevel&method=list',  
   			valueField:'codeValue',  
  	 		textField:'codeName',
  	 		panelHeight:'auto',
  	 		editable:false,
  	 		onLoadSuccess:function(){
  				//不让第一条为默认选择项
  				$('#problemLevel').combobox('unselect',0);
  				$('#problemLevel').combobox('setValue',null);
  			}
		});
		//渲染问题来源下拉框
		$('#problemOrigin').combobox({
			url:'${pageContext.request.contextPath}/problemmgr/problemAction!getDic.action?codeType=requireSrc&method=list',  
   			valueField:'codeValue',  
  	 		textField:'codeName',
  	 		panelHeight:'auto',
  	 		editable:false,
  	 		onLoadSuccess:function(){
  				//不让第一条为默认选择项
  				$('#problemOrigin').combobox('unselect',0);
  				$('#problemOrigin').combobox('setValue',null);
  			}
		});
		//日期组件
		$('#discoveryTime').my97({
			dateFmt:'yyyy-MM-dd',
			startDate:[{
				doubleCalendar:false,
				isShowWeek:false,
				isShowClear:false,
				readOnly:true
				 
			}]
		});
	});
	
	//查询数据方法
	function getDatagridByID()
	{
		$("#problemDealTab").datagrid({
			url : '${pageContext.request.contextPath}/problemmgr/problemAction!getProblemDealByID.action',
			queryParams:serializeObject($('#deal_form')),
			fit:true,
			border:false,
			fitColumns:true,
			pagination:true,
			pageList:[10,20,30],
			rownumbers:true,
			singleSelect:false,
			pagePosition:'bottom',
			autoRowHeight:true,
			rownumbers:false,
			sortName:'discoveryTime',
			sortOrder:'desc',
			striped:true,
			columns:[[  {field:'title',title:'问题主题',width:160,align:'left',sortable:true,formatter:function(value,rowData,rowIndex){
							return '<div onmouseover="onMouseOverName(this)"  onmouseout="onMouseOutName(this)" onclick="showProblem('+rowData.problemId+','+rowData.taskId+')" style="color:#2b76b7;cursor:pointer;width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="'+rowData.title+'">'+rowData.title+'</div>'
						
				
						}},
						{field:'keyWord',title:'关键字',width:120,align:'center',formatter:function(value,rowData,rowIndex){
			            	if(rowData.keyWord!=undefined){
			            		  return '<div style="width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="'+rowData.keyWord+'">'+rowData.keyWord+'</div>';
			            		  }

								}},
						{field:'problemLevel',title:'问题级别',width:60,align:'center',sortable:true,formatter:function(value,rowData,rowIndex){
							if(rowData.problemLevel=="0"){
								   return "<span style='color:#7aba42'>提示</span>";
								  }else if(rowData.problemLevel=="1"){
								  	return "<span style='color:#8cbeed'>一般告警</span>";
								  }else if(rowData.problemLevel=="2"){
								  	return "<span style='color:#ff9200'>重要告警</span>";
								  }else if(rowData.problemLevel=="3"){
								  	return "<span style='color:#ec0101'>严重告警</span>";
								  }
								}},						
						{field:'discoveryTime',title:'发生时间',width:120,align:'center'},
						{field:'responsibler',title:'责任人',width:60,align:'center'},
						{field:'dsafd',title:'操作',width:80,align:'center',formatter:function(value,rowData,rowIndex){
							if(rowData.status=='0'){
								return '<span onclick="dealProblem('+rowData.problemId+','+rowData.taskId+','+rowData.executionId+')" style="cursor:pointer"><img  src="${pageContext.request.contextPath}/images/icons/deal_with.png" title="处理" alt="处理"/>处理</span>&nbsp;&nbsp;'
								  +'<span onclick="transProblem('+rowData.problemId+','+rowData.taskId+','+rowData.executionId+')"  style="cursor:pointer"><img src="${pageContext.request.contextPath}/images/icons/transpond.png" title="转发" alt="转发"/>转发</span>';
							
							}else if(rowData.status=='1'){
								return '<span onclick="dealProblem('+rowData.problemId+','+rowData.taskId+','+rowData.executionId+')" style="cursor:pointer"><img  src="${pageContext.request.contextPath}/images/icons/deal_with.png" title="处理" alt="处理"/>处理</span>&nbsp;&nbsp;'
								  +'<span onclick="transProblem('+rowData.problemId+','+rowData.taskId+','+rowData.executionId+')"  style="cursor:pointer"><img src="${pageContext.request.contextPath}/images/icons/transpond.png" title="转发" alt="转发"/>转发</span>';
							
							}else if(rowData.status=='2'){
								return '<span onclick="affirmProblem('+rowData.problemId+','+rowData.taskId+')" style="cursor:pointer"><img  src="${pageContext.request.contextPath}/images/icons/examine_and _verify.png" title="审核" alt="审核"/>审核</span>&nbsp;&nbsp;'
								  +'<span onclick="returnProblem('+rowData.problemId+','+rowData.taskId+')"  style="cursor:pointer"><img src="${pageContext.request.contextPath}/images/icons/rollback.png" title="回退" alt="回退"/>回退</span>';
							
							}
								  
							
						}}
						
					]],
			toolbar:'#problem_toobar'
		});
	}
	
	//分页查询
	function doQuery()
	{
		var dataGridOptions=$('#problemDealTab').datagrid('options');
		if($('#deal_form').form('validate'))
		{
			dataGridOptions.queryParams=serializeObject($('#deal_form'));
			$('#problemDealTab').datagrid(dataGridOptions);
			$('#problemDealTab').datagrid('load');
		}
	}

	//处理问题
	function dealProblem(problemId,taskId,executionId){		
		var pars="problemId="+problemId+"&taskId="+taskId+"&executionId="+executionId;
        window.top.$('<div/>').dialog({
			href:'${pageContext.request.contextPath}/problemmgr/problemAction!toDealProblemPage.action?'+pars,
			top:($(window).height()-250)*0.5,
		    left:($(window).width()-300)*0.5,
			width:730,
			title:'处理问题',
			modal:true,
			buttons:[{
				text:'处 理',
				iconCls:'',
				handler:function(){
					var d=window.top.$(this).closest('.window-body');
					window.top.$('#problem_deal_form').form('submit',{
						url:'${pageContext.request.contextPath}/problemmgr/problemAction!dealProblem.action',
						data:pars,
						success:function(result){
							try {
								var r = $.parseJSON(result);
								$.messager.show({
									title : '提示',
									msg : r.returnMsg
								});
								if (r.returnFlag) {
									d.dialog('destroy');
									pars='';
									getDatagridByID();
								}
								
							} catch (e) {
								$.messager.alert('提示', result);
							}
							
							}
						});
					}
				}],
			onClose:function(){
				window.top.$(this).dialog('destroy');
			}
		});
        
	}
	
	
	//转发
	function transProblem(problemId,taskId,executionId){		
        var pars="problemId="+problemId+"&taskId="+taskId+"&executionId="+executionId;
        window.top.$('<div/>').dialog({
			href:'${pageContext.request.contextPath}/problemmgr/problemAction!toTransProblemPage.action?'+pars,
			top:($(window).height()-250)*0.5,
		    left:($(window).width()-300)*0.5,
			width:730,
			modal:true,
			title:'转发问题',
			buttons:[{
				text:'转 发',
				iconCls:'',
				handler:function(){
					var d=window.top.$(this).closest('.window-body');
					window.top.$('#problem_trans_form').form('submit',{
						url:'${pageContext.request.contextPath}/problemmgr/problemAction!transProblem.action',
						data:pars,
						success:function(result){
							try {
								var r = $.parseJSON(result);
								$.messager.show({
									title : '提示',
									msg : r.returnMsg
								});
								if (r.returnFlag) {
									d.dialog('destroy');
									pars='';
									getDatagridByID();
								}
								
							} catch (e) {
								$.messager.alert('提示', result);
							}
							}
						});
					}
				}],
			onClose:function(){
				window.top.$(this).dialog('destroy');
			}
		});
        
	}
	
	//审核问题
	function affirmProblem(problemId,taskId){
		var pars="problemId="+problemId+"&taskId="+taskId;
        window.top.$('<div/>').dialog({
			href:'${pageContext.request.contextPath}/problemmgr/problemAction!toAffirmPage.action?'+pars,
			top:($(window).height()-250)*0.5,
		    left:($(window).width()-300)*0.5,
			width:730,
			modal:true,
			title:'审核问题',
			buttons:[{
				text:'审 核',
				iconCls:'',
				handler:function(){
					var d=window.top.$(this).closest('.window-body');
					window.top.$.messager.progress({title : '提示',text : '正在审核，请稍后 ....'});
					window.top.$('#problem_affirm_form').form('submit',{
						url:'${pageContext.request.contextPath}/problemmgr/problemAction!affirmProblem.action',
						data:pars,
						success:function(result){
							
							try {
								window.top.$.messager.progress('close');
								var r = $.parseJSON(result);
								$.messager.show({
									title : '提示',
									msg : r.returnMsg
								});
								if (r.returnFlag) {
									d.dialog('destroy');
									$('#deal_form').form('clear');
									getDatagridByID();
								}
								
							} catch (e) {
								$.messager.alert('提示', result);
								window.top.$.messager.progress('close');
							}
							}
						});
					}
				}],
			onClose:function(){
				window.top.$(this).dialog('destroy');
			}
		});
        
	}
	
	
	//回退
	function returnProblem(problemId,taskId){
		window.top.$.messager.confirm('回退确认', '确定要回退吗？', function(r){
			if (r){
				window.top.$.messager.progress({title : '提示',text : '正在回退，请稍后 ....'});
				var pars="problemId="+problemId+"&taskId="+taskId;
				$.ajax({
					 url :'${pageContext.request.contextPath}/problemmgr/problemAction!returnProblem.action',
					 data:pars,
					 dataType :'json',
					 success : function(r1){ 
						 window.top.$.messager.progress('close');
						 $.messager.show({
								title:'提示',
								msg:r1.returnMsg,
								showType:'slide'
							});
					       $('#deal_form').form('clear'); 
							getDatagridByID();
							window.top.$.messager.progress('close');
					 }
		         });	
			}
		});
		
		
	}
	
	//显示历史信息
	function showProblem(problemId,taskId){
		var pars="problemId="+problemId+"&taskId="+taskId;
		var d=window.top.$(this).closest('.window-body');
        window.top.$('<div/>').dialog({
			href:'${pageContext.request.contextPath}/problemmgr/problemAction!toShowProblemPage.action?'+pars,
			width:948,
			height:518,
			left:250,
			modal:true,
			title:'问题历史记录',
			onClose:function(){
				window.top.$(this).dialog('destroy');
			}
		});
	}
	
    //重置方法
    function resetData(){
    	$("#title").val('');
    	$('#problemLevel').combobox("setValue",null);
    	$('#problemOrigin').combobox("setValue",null);
    	$('#keyWord').val('');
    	$('#discoveryTime').val('');
    }
	</script>
</head>

<body class="easyui-layout">

<form id="deal_form" method="post">
  <div data-options="region:'north'" style="height:80px;border-bottom:none;border-top:none;" >
		<table border="0" cellpadding="0" cellspacing="0" height="100%"  width="100%">
			<tbody>
				<tr>
					<td style="width:10%;text-align:right;" nowrap="nowrap">
						<label for="reportnameQ">问题主题：</label>
					</td>
					<td style="width:15%;text-align:right;" nowrap="nowrap">
						<input name="title" id="title" class="easyui-validatebox" type="text"/> 
					</td>
					
					<td style="width:10%;text-align:right;" nowrap="nowrap">
						<label for="reportnameQ">问题级别：</label>
					</td>
					<td style="width:15%;text-align:right;" nowrap="nowrap">
						<input id="problemLevel" class="easyui-combobox" panelHeight='auto' name="problemLevel"/>
					</td>
					<td style="width:10%;text-align:right;" nowrap="nowrap">
						<label for="reportnameQ">关键字：</label>
					</td>
					<td style="width:15%;text-align:right;" nowrap="nowrap">
						<input id="keyWord" name="keyWord" class="easyui-validatebox" type="text"/>
					</td>
					
					<td style="width:10%;text-align:right;" nowrap="nowrap">
						<label for="reportnameQ">问题来源：</label>
					</td>
					<td style="width:15%;text-align:left;padding-right:35px" nowrap="nowrap">
						<input id="problemOrigin" name="problemOrigin"/>
					</td>
				</tr>
				<tr>
					<td style="width:10%;text-align:right;" nowrap="nowrap">
						<label for="reportnameQ">发生时间：</label>
					</td>
					<td style="width:15%;text-align:right;" nowrap="nowrap">
						&nbsp;<input id="discoveryTime" type="date" name="discoveryTime"  style="height:20px;"></input>
					</td>
					<td style="width:10%;text-align:right;" nowrap="nowrap">
					</td>
					<td style="width:15%;text-align:right;" nowrap="nowrap">
					</td>
					<td style="width:10%;text-align:right;" nowrap="nowrap">
					</td>
					<td style="width:15%;text-align:right;" nowrap="nowrap">
					</td>
					<td colspan="2" style="width:25%;text-align:right;" nowrap="nowrap">	   
			    		<input type="button" onclick="doQuery()" value="查询" style="background-image: url('${pageContext.request.contextPath}/images/login/search.png');background-repeat: no-repeat;width:67px;height:23px;padding-left:12px;border:none;color:white;font-family:微软雅黑;cursor:pointer"/>	
			    		<input type="button" onclick="resetData()" value="重置" style="background-image: url('${pageContext.request.contextPath}/images/login/reset.png');background-repeat: no-repeat;width:67px;height:23px;padding-left:12px;border:none;color:white;font-family:微软雅黑;margin-right:35px;cursor:pointer"/>			
	    			</td>
	    			
					
					
				</tr>
			</tbody>
		</table>
	</div>	 
	<div data-options="region:'center'"  style="border:#ccc solid 1px;">  
		<table id="problemDealTab"></table>	
	</div>
	</form>
</body>
</html>
